// pages/detail-video/detail-video.js
import {
  getMVUrl,
  getMvInfo,
  getMVRelate
} from "../../../services/video"

Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: 0,
    mvUrl: '',
    mvInfo: {},
    relatedVideo: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    //获取id
    const id = options.id
    this.setData(id)

    //请求数据
    this.fetchMVUrl(id)
    this.fetchMVInfo(id)
    this.fetchMVRelated(id)
  },

  async fetchMVUrl(id) {
    const res = await getMVUrl(id)
    this.setData({
      mvUrl: res.data.url
    })
  },
  async fetchMVInfo(id) {
    const res = await getMvInfo(id)
    console.log(res);
    this.setData({
      mvInfo: res.data
    })
  },
  async fetchMVRelated(id) {
    const res = await getMVRelate(id)
    this.setData({
      relatedVideo: res.data
    })
  }

})